home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 9 / CDACTUAL9.iso / share / Dos / VARIOS / pascal / SWAG9605.DDD / 0100_Quickly Change DIRS.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-05-31  |  2.4 KB  |  133 lines

  1. {
  2. QCD (C) 1995 Scott Tunstall. All rights reserved.
  3. -------------------------------------------------
  4.  
  5. Using a text file that you have created (called DIRS.TXT) this
  6. routine can quickly CD into any directory without you having
  7. to specify the full path.
  8.  
  9. (Mind and not overload the table with entries please... will
  10. slow down the old CPU)
  11.  
  12.  
  13.  
  14. For example, in file DIRS.TXT
  15.  
  16. You could have:
  17.  
  18. DUNE2
  19. C:\GAMES\DUNE2
  20. ...
  21. ...
  22. ...
  23. ...
  24.  
  25.  
  26.  
  27. So whenever this was typed at the command line
  28. CDQ DUNE2
  29.  
  30. The directory becomes C:\GAMES\DUNE2
  31.  
  32.  
  33. You can have as many entries as you like.
  34.  
  35.  
  36. }
  37.  
  38. uses crt, basics;
  39.  
  40.  
  41.  
  42.  
  43.  
  44. procedure usage;
  45. begin
  46.  
  47.      writeln;
  48.      writeln('Usage :');
  49.      writeln;
  50.      writeln('QCD <Entry>');
  51.      writeln;
  52.      writeln('Where <Entry> is a key related to a specific path');
  53.      writeln('contained on the disk (need not be the current disk)');
  54.      writeln;
  55.      writeln('Ask Scott for details if still stuck :)');
  56.      writeln('E-Mail address: INSC3SAT@RIVER.TAY.AC.UK');
  57.      writeln;
  58.      halt;
  59. end;
  60.  
  61.  
  62.  
  63.  
  64.  
  65. Function StrCmp(Str1, Str2 : String) : Boolean;
  66. begin
  67.   Str1:=upper(Str1);
  68.   Str2:=upper(Str2);
  69.  
  70.   if (Length(Str1) = Length(Str2)) and (Pos(Str1, Str2) <> 0) then
  71.     StrCmp := True
  72.   else
  73.     StrCmp := False;
  74. end;
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. procedure change_dir(entry : string);
  82. var f: text;
  83.     currententry: string[20];
  84.     associateddir: string[80];
  85.  
  86. begin
  87.      assign(f, '\DIRS.TXT');
  88.      reset(f);
  89.      while not eof(f) do
  90.      begin
  91.           readln(f,currententry);
  92.           readln(f,associateddir);
  93.           if (strcmp(entry, currententry) = True) then
  94.              begin
  95.              close(f);
  96.              {$i-}
  97.              chdir(associateddir);
  98.              if ioresult <> 0 then
  99.                 begin
  100.                 writeln('Directory ',upper(associateddir),' does not exist !!');
  101.                 halt(1);
  102.                 end;
  103.              halt(0);
  104.           end;
  105.      end;
  106.  
  107.      writeln;
  108.      writeln('No match for ',upper(entry),'!. ');
  109.      close(f);
  110.      halt(1);
  111. end;
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118. begin
  119.      writeln;
  120.      writeln;
  121.      writeln('Quick CD (C) 1995 Scott Tunstall. All rights reserved.');
  122.  
  123.      case paramcount of
  124.      0 : usage;
  125.      1 : change_dir(paramstr(1));
  126.      else
  127.          begin
  128.          writeln('An error occurred: Too many parameters !!');
  129.          usage;
  130.          end;
  131.      end;
  132.  
  133. end.